app.controller("billingDataMoveCtrl", function ($scope,$interval, $http, billingDataMoveService) {


    //-----------------------------

    $scope.object = {};
    $scope.formMode = false;
    $scope.errors = {};

    //--------------初始化菜单---------------
    $scope.initMenu = function () {
        showSecondMenu('billingManage');
        selectSecondMenu('billingDataMove');
    }
    $scope.initMenu();

    //注意事项
    $scope.showtips = function () {
        billingDataMoveService.showtips({
            action: 'showtips'
        }, function (data) {
            if (data.status == "SUCCESS") {
                if(data.data.Tip1!=''){
                    $("#tip1").html(data.data.Tip1);
                    $("#tip1").show();
                }else {
                    $("#tip1").hide();
                }

                if(data.data.Tip2!=''){
                    $("#tip2").html(data.data.Tip2);
                    $("#tip2").show();
                }else {
                    $("#tip2").hide();
                }

            }
        });
    }
    $scope.showtips();

    //---------------错误信息--------------
    $scope.requestError = function () {
        $scope.errorMessage = "unknown error!"
    };

    $scope.init = function () {
        $scope.startDate = getDateFunction(0);  //开始日期
        $scope.endDate = getDateFunction(0);    //结束日期
    };

    //同步基础数据
    $scope.movebase = function () {
        billingDataMoveService.movebase({
            action: 'movebase'
        }, function (data) {
            if (data.status == "SUCCESS") {
                promptMsg("同步数据成功！");
                $scope.showtips();
            } else {
                promptMsg("同步数据失败："+data.errorReason);
            }
        }, $scope.requestError());
    }

    //同步舱单名单数据
    $scope.movelsandps = function () {
        if(NullOrUndefined($("#startDate").val())){
            promptMsg("请选择开始日期！");
            return false;
        }
        if(NullOrUndefined($("#endDate").val())){
            promptMsg("请选择结束日期！");
            return false;
        }
        billingDataMoveService.movelsandps({
            action: 'movelsandps',
            startDate: $("#startDate").val(),
            endDate: $("#endDate").val(),
        }, function (data) {
            if (data.status == "SUCCESS") {
                promptMsg("同步数据成功！"+data.data.Tips);
            } else {
                promptMsg("同步数据失败："+data.errorReason);
            }
            $scope.showtips();
        }, $scope.requestError());
    }

    // $scope.requestError = function (error) {
    //     $scope.errorMessage = "unknown error!";
    // };

});
